package xidian.vlab.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;
import xidian.vlab.dto.FormDTO;
import xidian.vlab.dto.QueryDTO;
import xidian.vlab.dto.ResJsonDTO;
import xidian.vlab.service.RoomService;
import xidian.vlab.utils.ResUtil;

@RestController
@RequestMapping("/room")
public class RoomController {
    @Autowired
    private RoomService roomService;

    @GetMapping("/list")
    public ResJsonDTO getRooms(@RequestHeader HttpHeaders headers, QueryDTO query){
        if (query == null) return ResUtil.ERROR("未提供参数");
        return roomService.getList(query);
    }
    @PostMapping("/update")
    public ResJsonDTO updateRoom(@RequestBody QueryDTO query){
        if (query == null) return ResUtil.ERROR("未提供参数");
        return roomService.updateRoom(query);
    }
    @PostMapping("/create")
    public ResJsonDTO createRoom(FormDTO form){
        if (form == null) return ResUtil.ERROR("未提供表单");
        return roomService.createRoom(form);
    }
    @PostMapping("/remove")
    public ResJsonDTO removeRoom(@RequestBody QueryDTO query){
        if (query == null) return ResUtil.ERROR("未提供表单");
        return roomService.removeRoom(query);
    }

}
